<template>
  <view v-if="isShow" class="popup-overlay" @click="handleClick">
    <image :class="{ 'shrink-animation': isClicked, 'scale-animation': isShow }" mode="widthFix"
      :src="compInfo.receive_image"></image>
    <view v-if="isShow & !isClicked" class="happy-btn claiming-btn">
<!--      <image mode="widthFix" src="http://yyadmin.laimeitong.com/images/happyBtn.png"></image>-->
      <text class="btn-text">开心收下</text>
    </view>
  </view>
</template>
<script>
const app = getApp();
import newUserRewardApi from '@/api/newUserReward.js'
export default {
  data() {
    return {
      isClicked: false,
      isShow: false,
      BestImgUrl: app.globalData.imgurl,
      compInfo: {},
    }
  },
  props:{
    showTemp: {
      type: Number,
      default: 2
    }
  },
  computed: {
    showImageUrl() {
      return this.showTemp == 2 ? `${this.BestImgUrl}/Mask-group-2.png` : `http://yyadmin.laimeitong.com/images/weixinPayment.png`
    }
  },
  methods: {
    showUp() {
      //获取省份判断是否显示旧版提现入口
      let CityName = uni.getStorageSync('CityName')
      let Province = uni.getStorageSync('Province')
      const submitData = {
        province: Province,
        city: CityName
      }
      newUserRewardApi.getNewUserReward(submitData).then(res => {
        const data = res.data
        console.log('showTemp==',this.showTemp)
        const {result , code} = data
        if (code == 200 && result && result.length) {
          if (this.showTemp === 2 ){
            this.compInfo = result[0]
          } else if( this.showTemp === 1) {
            this.compInfo = result[1]
          }
          /*if ( this.compInfo.is_receive == 0  && this.showTemp == 3) { // 未绑定手机号
            const myphone = uni.getStorageSync('userinfo').username
            if (!myphone) {
              uni.$on('bindphone',(flag)=>{
                if (flag) {
                  this.isShow = true;
                }
              })
              uni.navigateTo({
                url: '/mePages/pages/Bindphone?laiyuan=' + 'userReward',
                animationType: 'pop-in'
              })
              return
            }
            this.isShow = true;
            return
          }*/
          this.isShow = true;
        }
      })
    },
    handleClick() {
      this.isClicked = true;

      // 可选：动画结束后移除元素
      setTimeout(() => {
        // this.$destroy() // 根据实际需求决定是否要销毁组件
        this.isShow = false;
        this.isClicked = false
        this.$emit('addAmount', this.compInfo)
      }, 1000)
    }
  }
}
</script>
<style>
@import "./css/index-xg.css";
@import "./css/animation.css";
</style>